/* eslint-disable @next/next/no-sync-scripts */
import Document, { Html, Head, Main, NextScript } from 'next/document'
import { isMobile } from "@/common/tool"
class MyDocument extends Document {
  constructor(props) {
    super(props)
  }
  static getInitialProps = async (ctx) => {
    const initialProps = await Document.getInitialProps(ctx)
    const mobile = isMobile(ctx?.req?.headers['user-agent'])
    return { ...initialProps, mobile }
  }
  render () {
    const { mobile } = this.props
    return (
      <Html style={{ '--rootFontSize': mobile ? '13.3333334vw' : '14px' }}>
        <Head />
        <body>
          <Main />

          <NextScript />
        </body>
        <script src='/statistics.js'></script>
      </Html>
    )
  }
}

export default MyDocument